public class LCA {
    public int getLCA(int a, int b) {
        while(a>=1&&b>=1){
        if((b+1)/2==a){
            return a;
        }
        if((a+1)/2==b){
            return b;
        }
           if(a>b){
               a=(a+1)/2;
           }else{
               b=(b+1)/2;
           }
        }
     return a;
    }
}